

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="深海火锅店">
  <meta name="keywords" content="">
  
    <meta name="description" content="支付宝沙箱支付 参考博客1 参考博客2 网站 参考视频,青戈的demo项目    密钥   导入依赖  1234567891011&lt;dependency&gt;    &lt;groupId&gt;com.alipay.sdk&lt;&#x2F;groupId&gt;    &lt;artifactId&gt;alipay-sdk-java&lt;&#x2F;artifactId&gt;    &lt;vers">
<meta property="og:type" content="article">
<meta property="og:title" content="支付宝沙箱支付">
<meta property="og:url" content="http://example.com/2023/03/27/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Java/%E5%AD%A6%E4%B9%A0/%E6%A1%86%E6%9E%B6/SpringBoot/%E6%94%AF%E4%BB%98%E5%AE%9D%E6%B2%99%E7%AE%B1%E6%94%AF%E4%BB%98/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="支付宝沙箱支付 参考博客1 参考博客2 网站 参考视频,青戈的demo项目    密钥   导入依赖  1234567891011&lt;dependency&gt;    &lt;groupId&gt;com.alipay.sdk&lt;&#x2F;groupId&gt;    &lt;artifactId&gt;alipay-sdk-java&lt;&#x2F;artifactId&gt;    &lt;vers">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337963.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337090.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337207.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337844.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337268.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337560.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337177.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337241.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337915.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337442.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338191.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337401.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338219.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338689.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338811.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338582.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338306.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338384.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338458.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338705.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338134.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338575.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338417.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338042.png">
<meta property="article:published_time" content="2023-03-27T03:00:00.000Z">
<meta property="article:modified_time" content="2024-02-15T15:39:15.373Z">
<meta property="article:author" content="深海火锅店">
<meta property="article:tag" content="支付宝沙箱支付">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337963.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>支付宝沙箱支付 - Hexo</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fluid</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/background.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="支付宝沙箱支付"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-03-27 11:00" pubdate>
          2023年3月27日 上午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          6.5k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          55 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">支付宝沙箱支付</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="支付宝沙箱支付"><a href="#支付宝沙箱支付" class="headerlink" title="支付宝沙箱支付"></a>支付宝沙箱支付</h1><blockquote>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/hhb442/article/details/123304287">参考博客1</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/xqnode/article/details/124457790">参考博客2</a></p>
<p><a target="_blank" rel="noopener" href="https://open.alipay.com/develop/sandbox/app">网站</a></p>
<p><a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV12e4y1o7qj/?spm_id_from=333.337.search-card.all.click&vd_source=0de2cc95ad0adc3e9ec15f6dcede1a20">参考视频</a>,<a target="_blank" rel="noopener" href="https://gitee.com/xqnode/alipay-demo">青戈的demo项目</a></p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337963.png" srcset="/img/loading.gif" lazyload alt="步骤1"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337090.png" srcset="/img/loading.gif" lazyload alt="image-20230326134943080"></p>
<p><a target="_blank" rel="noopener" href="https://opendocs.alipay.com/common/02kipk#%E5%B7%A5%E5%85%B7%E4%B8%8B%E8%BD%BD">密钥</a></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337207.png" srcset="/img/loading.gif" lazyload alt="image-20230326203237561"></p>
<blockquote>
<p>导入依赖</p>
</blockquote>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.alipay.sdk<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>alipay-sdk-java<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>4.22.110.ALL<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>cn.hutool<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>hutool-all<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>5.7.20<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br></code></pre></td></tr></table></figure>

<blockquote>
<p>application.properties里需要配置这四个</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337844.png" srcset="/img/loading.gif" lazyload alt="image-20230326212330514"></p>
<blockquote>
<p>这里复制第一个appid</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337268.png" srcset="/img/loading.gif" lazyload alt="appId"></p>
<blockquote>
<p>复制第二个私钥</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337560.png" srcset="/img/loading.gif" lazyload alt="image-20230326212621235"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337177.png" srcset="/img/loading.gif" lazyload alt="image-20230326212657145"></p>
<blockquote>
<p>复制第三个支付宝公钥</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337241.png" srcset="/img/loading.gif" lazyload alt="image-20230326212806008"></p>
<blockquote>
<p>至于第四个url，需要下载一个工具</p>
</blockquote>
<h2 id="natapp地址"><a href="#natapp地址" class="headerlink" title="natapp地址"></a>natapp地址</h2><p>官网：<a target="_blank" rel="noopener" href="https://natapp.cn/">https://natapp.cn/</a></p>
<p>下载：<a target="_blank" rel="noopener" href="https://pan.baidu.com/s/1L99Ibawylnck4b4c0NtmXg?pwd=685x">https://pan.baidu.com/s/1L99Ibawylnck4b4c0NtmXg?pwd=685x</a></p>
<blockquote>
<p>下载后，去官网注册账号</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337915.png" srcset="/img/loading.gif" lazyload alt="image-20230326213755393"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337442.png" srcset="/img/loading.gif" lazyload alt="image-20230326213914822"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338191.png" srcset="/img/loading.gif" lazyload alt="image-20230326213940611"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152337401.png" srcset="/img/loading.gif" lazyload alt="image-20230326214106638"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338219.png" srcset="/img/loading.gif" lazyload alt="image-20230326214209342"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338689.png" srcset="/img/loading.gif" lazyload alt="image-20230326214411891"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338811.png" srcset="/img/loading.gif" lazyload alt="image-20230326214512806"></p>
<blockquote>
<p>配好之后双击start.bat</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338582.png" srcset="/img/loading.gif" lazyload alt="image-20230326214657488"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338306.png" srcset="/img/loading.gif" lazyload alt="image-20230326214742135"></p>
<blockquote>
<p>还需要配置controller的地址</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338384.png" srcset="/img/loading.gif" lazyload alt="image-20230326214859892"></p>
<blockquote>
<p>配置到此结束</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338458.png" srcset="/img/loading.gif" lazyload alt="image-20230326215056683"></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">import</span> lombok.Data;<br><span class="hljs-keyword">import</span> org.springframework.boot.context.properties.ConfigurationProperties;<br><span class="hljs-keyword">import</span> org.springframework.stereotype.Component;<br><br><span class="hljs-meta">@Data</span><br><span class="hljs-meta">@Component</span><br><span class="hljs-meta">@ConfigurationProperties(prefix = &quot;alipay&quot;)</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">AliPayConfig</span> &#123;<br>    <span class="hljs-keyword">private</span> String appId;<br>    <span class="hljs-keyword">private</span> String appPrivateKey;<br>    <span class="hljs-keyword">private</span> String alipayPublicKey;<br>    <span class="hljs-keyword">private</span> String notifyUrl;<br>&#125;<br></code></pre></td></tr></table></figure>

<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338705.png" srcset="/img/loading.gif" lazyload alt="image-20230326215215436"></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">import</span> lombok.Data;<br><br><span class="hljs-meta">@Data</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">AliPay</span> &#123;<br>    <span class="hljs-keyword">private</span> String traceNo;<br>    <span class="hljs-keyword">private</span> <span class="hljs-type">double</span> totalAmount;<br>    <span class="hljs-keyword">private</span> String subject;<br>    <span class="hljs-keyword">private</span> String alipayTraceNo;<br>&#125;<br></code></pre></td></tr></table></figure>



<blockquote>
<p>继续新建<code>AliPayController</code>，把报错的<code>AliPayConfig</code>包换成自己项目里的路径，还有<code>Order</code></p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">import</span> cn.hutool.json.JSONObject;<br><span class="hljs-keyword">import</span> com.alipay.api.AlipayApiException;<br><span class="hljs-keyword">import</span> com.alipay.api.AlipayClient;<br><span class="hljs-keyword">import</span> com.alipay.api.DefaultAlipayClient;<br><span class="hljs-keyword">import</span> com.alipay.api.internal.util.AlipaySignature;<br><span class="hljs-keyword">import</span> com.alipay.api.request.AlipayTradePagePayRequest;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;<br><span class="hljs-keyword">import</span> com.example.alipay.common.AliPayConfig;<br><span class="hljs-keyword">import</span> com.example.alipay.dao.OrdersMapper;<br><span class="hljs-keyword">import</span> com.example.alipay.entity.Orders;<br><span class="hljs-keyword">import</span> org.springframework.web.bind.annotation.GetMapping;<br><span class="hljs-keyword">import</span> org.springframework.web.bind.annotation.PostMapping;<br><span class="hljs-keyword">import</span> org.springframework.web.bind.annotation.RequestMapping;<br><span class="hljs-keyword">import</span> org.springframework.web.bind.annotation.RestController;<br><br><span class="hljs-keyword">import</span> javax.annotation.Resource;<br><span class="hljs-keyword">import</span> javax.servlet.http.HttpServletRequest;<br><span class="hljs-keyword">import</span> javax.servlet.http.HttpServletResponse;<br><span class="hljs-keyword">import</span> java.util.Date;<br><span class="hljs-keyword">import</span> java.util.HashMap;<br><span class="hljs-keyword">import</span> java.util.Map;<br><br><span class="hljs-comment">// xjlugv6874@sandbox.com</span><br><span class="hljs-comment">// 9428521.24 - 30 = 9428491.24 + 30 = 9428521.24</span><br><span class="hljs-meta">@RestController</span><br><span class="hljs-meta">@RequestMapping(&quot;/alipay&quot;)</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">AliPayController</span> &#123;<br><br>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-type">String</span> <span class="hljs-variable">GATEWAY_URL</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;https://openapi.alipaydev.com/gateway.do&quot;</span>;<br>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-type">String</span> <span class="hljs-variable">FORMAT</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;JSON&quot;</span>;<br>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-type">String</span> <span class="hljs-variable">CHARSET</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;UTF-8&quot;</span>;<br>    <span class="hljs-comment">//签名方式</span><br>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-type">String</span> <span class="hljs-variable">SIGN_TYPE</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;RSA2&quot;</span>;<br><br>    <span class="hljs-meta">@Resource</span><br>    <span class="hljs-keyword">private</span> AliPayConfig aliPayConfig;<br><br>    <span class="hljs-meta">@Resource</span><br>    <span class="hljs-keyword">private</span> OrdersMapper ordersMapper;<br><br>    <span class="hljs-meta">@GetMapping(&quot;/pay&quot;)</span> <span class="hljs-comment">// &amp;subject=xxx&amp;traceNo=xxx&amp;totalAmount=xxx</span><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">pay</span><span class="hljs-params">(AliPay aliPay, HttpServletResponse httpResponse)</span> <span class="hljs-keyword">throws</span> Exception &#123;<br>        <span class="hljs-comment">// 1. 创建Client，通用SDK提供的Client，负责调用支付宝的API</span><br>        <span class="hljs-type">AlipayClient</span> <span class="hljs-variable">alipayClient</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">DefaultAlipayClient</span>(GATEWAY_URL, aliPayConfig.getAppId(),<br>                aliPayConfig.getAppPrivateKey(), FORMAT, CHARSET, aliPayConfig.getAlipayPublicKey(), SIGN_TYPE);<br><br>        <span class="hljs-comment">// 2. 创建 Request并设置Request参数</span><br>        <span class="hljs-type">AlipayTradePagePayRequest</span> <span class="hljs-variable">request</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">AlipayTradePagePayRequest</span>();  <span class="hljs-comment">// 发送请求的 Request类</span><br>        request.setNotifyUrl(aliPayConfig.getNotifyUrl());<br>        <span class="hljs-type">JSONObject</span> <span class="hljs-variable">bizContent</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">JSONObject</span>();<br>        bizContent.set(<span class="hljs-string">&quot;out_trade_no&quot;</span>, aliPay.getTraceNo());  <span class="hljs-comment">// 我们自己生成的订单编号</span><br>        bizContent.set(<span class="hljs-string">&quot;total_amount&quot;</span>, aliPay.getTotalAmount()); <span class="hljs-comment">// 订单的总金额</span><br>        bizContent.set(<span class="hljs-string">&quot;subject&quot;</span>, aliPay.getSubject());   <span class="hljs-comment">// 支付的名称</span><br>        bizContent.set(<span class="hljs-string">&quot;product_code&quot;</span>, <span class="hljs-string">&quot;FAST_INSTANT_TRADE_PAY&quot;</span>);  <span class="hljs-comment">// 固定配置</span><br>        request.setBizContent(bizContent.toString());<br><br>        <span class="hljs-comment">// 执行请求，拿到响应的结果，返回给浏览器</span><br>        <span class="hljs-type">String</span> <span class="hljs-variable">form</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;&quot;</span>;<br>        <span class="hljs-keyword">try</span> &#123;<br>            form = alipayClient.pageExecute(request).getBody(); <span class="hljs-comment">// 调用SDK生成表单</span><br>        &#125; <span class="hljs-keyword">catch</span> (AlipayApiException e) &#123;<br>            e.printStackTrace();<br>        &#125;<br>        httpResponse.setContentType(<span class="hljs-string">&quot;text/html;charset=&quot;</span> + CHARSET);<br>        httpResponse.getWriter().write(form);<span class="hljs-comment">// 直接将完整的表单html输出到页面</span><br>        httpResponse.getWriter().flush();<br>        httpResponse.getWriter().close();<br>    &#125;<br><br>    <span class="hljs-meta">@PostMapping(&quot;/notify&quot;)</span>  <span class="hljs-comment">// 注意这里必须是POST接口</span><br>    <span class="hljs-keyword">public</span> String <span class="hljs-title function_">payNotify</span><span class="hljs-params">(HttpServletRequest request)</span> <span class="hljs-keyword">throws</span> Exception &#123;<br>        <span class="hljs-keyword">if</span> (request.getParameter(<span class="hljs-string">&quot;trade_status&quot;</span>).equals(<span class="hljs-string">&quot;TRADE_SUCCESS&quot;</span>)) &#123;<br>            System.out.println(<span class="hljs-string">&quot;=========支付宝异步回调========&quot;</span>);<br><br>            Map&lt;String, String&gt; params = <span class="hljs-keyword">new</span> <span class="hljs-title class_">HashMap</span>&lt;&gt;();<br>            Map&lt;String, String[]&gt; requestParams = request.getParameterMap();<br>            <span class="hljs-keyword">for</span> (String name : requestParams.keySet()) &#123;<br>                params.put(name, request.getParameter(name));<br>                <span class="hljs-comment">// System.out.println(name + &quot; = &quot; + request.getParameter(name));</span><br>            &#125;<br><br>            <span class="hljs-type">String</span> <span class="hljs-variable">outTradeNo</span> <span class="hljs-operator">=</span> params.get(<span class="hljs-string">&quot;out_trade_no&quot;</span>);<br>            <span class="hljs-type">String</span> <span class="hljs-variable">gmtPayment</span> <span class="hljs-operator">=</span> params.get(<span class="hljs-string">&quot;gmt_payment&quot;</span>);<br>            <span class="hljs-type">String</span> <span class="hljs-variable">alipayTradeNo</span> <span class="hljs-operator">=</span> params.get(<span class="hljs-string">&quot;trade_no&quot;</span>);<br><br>            <span class="hljs-type">String</span> <span class="hljs-variable">sign</span> <span class="hljs-operator">=</span> params.get(<span class="hljs-string">&quot;sign&quot;</span>);<br>            <span class="hljs-type">String</span> <span class="hljs-variable">content</span> <span class="hljs-operator">=</span> AlipaySignature.getSignCheckContentV1(params);<br>            <span class="hljs-type">boolean</span> <span class="hljs-variable">checkSignature</span> <span class="hljs-operator">=</span> AlipaySignature.rsa256CheckContent(content, sign, aliPayConfig.getAlipayPublicKey(), <span class="hljs-string">&quot;UTF-8&quot;</span>); <span class="hljs-comment">// 验证签名</span><br>            <span class="hljs-comment">// 支付宝验签</span><br>            <span class="hljs-keyword">if</span> (checkSignature) &#123;<br>                <span class="hljs-comment">// 验签通过</span><br>                System.out.println(<span class="hljs-string">&quot;交易名称: &quot;</span> + params.get(<span class="hljs-string">&quot;subject&quot;</span>));<br>                System.out.println(<span class="hljs-string">&quot;交易状态: &quot;</span> + params.get(<span class="hljs-string">&quot;trade_status&quot;</span>));<br>                System.out.println(<span class="hljs-string">&quot;支付宝交易凭证号: &quot;</span> + params.get(<span class="hljs-string">&quot;trade_no&quot;</span>));<br>                System.out.println(<span class="hljs-string">&quot;商户订单号: &quot;</span> + params.get(<span class="hljs-string">&quot;out_trade_no&quot;</span>));<br>                System.out.println(<span class="hljs-string">&quot;交易金额: &quot;</span> + params.get(<span class="hljs-string">&quot;total_amount&quot;</span>));<br>                System.out.println(<span class="hljs-string">&quot;买家在支付宝唯一id: &quot;</span> + params.get(<span class="hljs-string">&quot;buyer_id&quot;</span>));<br>                System.out.println(<span class="hljs-string">&quot;买家付款时间: &quot;</span> + params.get(<span class="hljs-string">&quot;gmt_payment&quot;</span>));<br>                System.out.println(<span class="hljs-string">&quot;买家付款金额: &quot;</span> + params.get(<span class="hljs-string">&quot;buyer_pay_amount&quot;</span>));<br><br>                <span class="hljs-comment">// 查询订单</span><br>                QueryWrapper&lt;Orders&gt; queryWrapper = <span class="hljs-keyword">new</span> <span class="hljs-title class_">QueryWrapper</span>&lt;&gt;();<br>                queryWrapper.eq(<span class="hljs-string">&quot;order_id&quot;</span>, outTradeNo);<br>                <span class="hljs-type">Orders</span> <span class="hljs-variable">orders</span> <span class="hljs-operator">=</span> ordersMapper.selectOne(queryWrapper);<br><br>                <span class="hljs-keyword">if</span> (orders != <span class="hljs-literal">null</span>) &#123;<br>                    orders.setAlipayNo(alipayTradeNo);<br>                    orders.setPayTime(<span class="hljs-keyword">new</span> <span class="hljs-title class_">Date</span>());<br>                    orders.setState(<span class="hljs-string">&quot;已支付&quot;</span>);<br>                    ordersMapper.updateById(orders);<br>                &#125;<br>            &#125;<br>        &#125;<br>        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;success&quot;</span>;<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338134.png" srcset="/img/loading.gif" lazyload alt="image-20230326220353675"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs url">http://localhost:15000/alipay/pay?subject=香蕉&amp;traceNo=202208221661165525068&amp;totalAmount=6.99<br></code></pre></td></tr></table></figure>

<blockquote>
<p>可以看到这里是502，奇怪，视频上明明是这样做的，上网搜了一下，发现<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_46978751/article/details/111577414">博客</a><code>每周日中午12点至每周一中午12点沙箱环境进行维护</code>，今天是周日</p>
<p>官方也说了，请<a target="_blank" rel="noopener" href="https://opendocs.alipay.com/support/01razf">查看</a></p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338575.png" srcset="/img/loading.gif" lazyload alt="image-20230327203933130"></p>
<blockquote>
<p>ok，过了时间就可以打开了</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338417.png" srcset="/img/loading.gif" lazyload alt="image-20230327205301864"></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs java">商家信息<br>商户账号rilvmb5932<span class="hljs-meta">@sandbox</span>.com<br>登录密码<span class="hljs-number">111111</span><br>商户PID2088621987551356<br>账户余额<span class="hljs-number">2132135.00</span><br>买家信息<br>买家账号xesgkm3338<span class="hljs-meta">@sandbox</span>.com<br>登录密码<span class="hljs-number">111111</span><br>支付密码<span class="hljs-number">111111</span><br>用户UID2088622987164881<br>用户名称xesgkm3338<br>证件类型IDENTITY_CARD<br>证件账号<span class="hljs-number">308282195800026310</span><br>账户余额<span class="hljs-number">99999.00</span> <br></code></pre></td></tr></table></figure>

<blockquote>
<p>这里我遇到了一个问题，没有执行回调，我上网查了一下，找到这篇<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_45000856/article/details/125671735">博客</a>，但是我不是这个原因</p>
</blockquote>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202402152338042.png" srcset="/img/loading.gif" lazyload alt="image-20230327213001891"></p>
<p>这个url，复制粘贴到<code>alipay.notifyUrl</code>这里，<code>这个url每次启动都会改变，所以应该更改properties</code></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E6%94%AF%E4%BB%98%E5%AE%9D%E6%B2%99%E7%AE%B1%E6%94%AF%E4%BB%98/" class="category-chain-item">支付宝沙箱支付</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E6%94%AF%E4%BB%98%E5%AE%9D%E6%B2%99%E7%AE%B1%E6%94%AF%E4%BB%98/">#支付宝沙箱支付</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>支付宝沙箱支付</div>
      <div>http://example.com/2023/03/27/编程语言/Java/学习/框架/SpringBoot/支付宝沙箱支付/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>深海火锅店</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年3月27日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2023/04/01/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Java/%E5%AD%A6%E4%B9%A0/%E5%9F%BA%E7%A1%80/009_Java%E6%B3%9B%E5%9E%8B/" title="Java泛型">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Java泛型</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2023/03/27/%E7%B3%BB%E7%BB%9F%E9%85%8D%E7%BD%AE/%E7%BC%96%E7%A8%8B%E9%85%8D%E7%BD%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/%E6%B7%BB%E5%8A%A0%E5%8F%B3%E9%94%AE%E4%BB%A5XXX%E7%9A%84%E6%96%B9%E5%BC%8F%E6%89%93%E5%BC%80/%E6%B7%BB%E5%8A%A0%E5%8F%B3%E9%94%AE%E4%BB%A5XXX%E7%9A%84%E6%96%B9%E5%BC%8F%E6%89%93%E5%BC%80/" title="添加&#34;通过XXX打开&#34;的右键菜单">
                        <span class="hidden-mobile">添加&#34;通过XXX打开&#34;的右键菜单</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  
<script src="//cdn.jsdelivr.net/gh/EmoryHuang/BlogBeautify@1.1/DynamicRibbon.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
